package com.itheima.job;

import java.lang.reflect.Constructor;

public class Test02 {
    public static void main(String[] args) throws Exception{
        Class clazz = Class.forName("com.itheima.job.Student");

        //方法一：
        Student stu1 = (Student) clazz.newInstance();
        System.out.println(stu1.getName());

        //方法二：
        Constructor con = clazz.getConstructor(int.class, String.class);
        Student stu2 = (Student) con.newInstance(20, "张三");
        System.out.println(stu2.getName()+ stu2.getAge());
    }
}
